Available extra space could be less than zero
authorKristian Rietveld <kris@gtk.org>
Sun, 14 Nov 2010 09:43:00 +0000 (10:43 +0100)
committerKristian Rietveld <kris@gtk.org>
Sun, 28 Nov 2010 18:54:18 +0000 (19:54 +0100)
The allocated size, or (horizontally speaking) for-width size, can be
smaller than the sum of all minimum widths.  For example when the user
is resizing tree view columns manually.

gtk/gtkcellareabox.c
gtk/gtkcellareaboxcontext.c

index c29e260ad0e46922735b498f9396b6d55fbf3846..99b5b41685d3fbae431698eca4a52a77b3c1c90e 100644 (file)
@@ -770,7 +770,10 @@ get_allocated_cells (GtkCellAreaBox        *box,
 
          /* Distribute cells naturally within the group */
          avail_size -= (visible_cells - 1) * priv->spacing;
-         avail_size = gtk_distribute_natural_allocation (avail_size, visible_cells, sizes);
+          if (avail_size > 0)
+            avail_size = gtk_distribute_natural_allocation (avail_size, visible_cells, sizes);
+          else
+            avail_size = 0;
 
          /* Calculate/distribute expand for cells */
          if (expand_cells > 0)
@@ -1535,7 +1538,10 @@ compute_group_size_for_opposing_orientation (GtkCellAreaBox     *box,
       for (i = 0; i < n_sizes; i++)
        avail_size -= orientation_sizes[i].minimum_size;
 
-      avail_size = gtk_distribute_natural_allocation (avail_size, n_sizes, orientation_sizes);
+      if (avail_size > 0)
+        avail_size = gtk_distribute_natural_allocation (avail_size, n_sizes, orientation_sizes);
+      else
+        avail_size = 0;
 
       /* Calculate/distribute expand for cells */
       if (group->expand_cells > 0)
@@ -1607,7 +1613,10 @@ compute_size_for_opposing_orientation (GtkCellAreaBox        *box,
   for (i = 0; i < n_groups; i++)
     avail_size -= orientation_sizes[i].minimum_size;
 
-  avail_size = gtk_distribute_natural_allocation (avail_size, n_groups, orientation_sizes);
+  if (avail_size > 0)
+    avail_size = gtk_distribute_natural_allocation (avail_size, n_groups, orientation_sizes);
+  else
+    avail_size = 0;
 
   /* Calculate/distribute expand for groups */
   if (n_expand_groups > 0)
index 19fd36e656e74982ec1af943400a317b84d7335e..d4755499a7d30dd535c222f640f6c89eb06e7837 100644 (file)
@@ -412,7 +412,10 @@ allocate_for_orientation (GtkCellAreaBoxContext *context,
   for (i = 0; i < n_groups; i++)
     avail_size -= sizes[i].minimum_size;
 
-  avail_size = gtk_distribute_natural_allocation (avail_size, n_groups, sizes);
+  if (avail_size > 0)
+    avail_size = gtk_distribute_natural_allocation (avail_size, n_groups, sizes);
+  else
+    avail_size = 0;
 
   /* Calculate/distribute expand for groups */
   if (n_expand_groups > 0)